-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check block_timestamp always increases. #638
Conversation
// In other words, we range-check `diff = timestamp - prev_timestamp - 1` | ||
// between 0 and 2ˆ32. | ||
let diff = builder.sub(timestamp, prev_timestamp); | ||
let diff = builder.add_const(diff, F::NEG_ONE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should do a minus 1 here. Timestamp is UNIX based, in seconds if I'm correct. If a chain were to have a block time of < 1 sec this check would fail. We should probably allow for 0 diff.
) { | ||
// We check that timestamp >= prev_timestamp. | ||
// In other words, we range-check `diff = timestamp - prev_timestamp` | ||
// between 0 and 2ˆ32. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// between 0 and 2ˆ32. | |
// is between 0 and 2ˆ32. |
This PR aims at addressing #634.
In
create_block_circuit
, it range-checksdiff = timestamp - parent_timestamp - 1
between0
and2ˆ32
, as a way to ensuretimestamp > parent_timestamp
.